import JsCookie from "js-cookie";

export const getCookie = JsCookie.get;

export const setCookie = JsCookie.set;

export const removeCookie = JsCookie.remove;

/**
 * 清除所有cookie函数
 */
export const clearAllCookie: (extraKeys?: string[]) => void = (
  extraKeys = []
) => {
  const keys = document.cookie.match(/[^ =;]+(?==)/g) || [];

  [...keys, ...extraKeys].forEach((key: string) => {
    removeCookie(key);
  });
};
